package com.coding.mybatis;

import lombok.AllArgsConstructor;

import java.io.InputStream;

/**
 * @ClassName SqlSessionFactoryBuilder
 * @Author ykx
 * @Date 2023/12/31 19:25
 * @Version 1.0
 */
@AllArgsConstructor
public class SqlSessionFactoryBuilder {

    private Configuration configuration;

    public SqlSessionFactoryBuilder() {
        this.configuration = new Configuration();
    }

    public SqlSessionFactory build(InputStream inputStream) throws Exception {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(configuration);
        Configuration config = xmlConfigBuilder.parseConfiguration(inputStream);
        return new DefaultSqlSessionFactory(config);
    }

}
